Bun for Windows is here! Check out what's new in Bun 1.1 →

Bun
Bun v1.1.38 is here! →

Bun is a fast JavaScript
all-in-one toolkit|

Develop, test, run, and bundle JavaScript & TypeScript projects—all with Bun. Bun is an all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager.

$ bun run

Bun is a JavaScript runtime.

Bun is a new JavaScript runtime built from scratch to serve the modern JavaScript ecosystem. It has three major design goals:

Bun is designed as a drop-in replacement for Node.js. It natively implements hundreds of Node.js and Web APIs, including fs, path, Buffer and more.

The goal of Bun is to run most of the world's server-side JavaScript and provide tools to improve performance, reduce complexity, and multiply developer productivity.

Drop-in Node.js compatibility

Bun aims to be a drop-in replacement for Node.js. It implements Node's module resolution algorithm, globals like Buffer and process, and built-in modules like fs and path. Click to track Bun's progress towards full compatibility.

Fast running performance

Bun extends the JavaScriptCore engine—the performance-minded JS engine built for Safari—with native-speed functionality implemented in Zig.

Works with node_modules

With Bun, you still use package.json to manage your dependencies. Use Bun's native npm client to see just how fast installing dependencies can be.

No more module madness

Forget the complicated rules around CommonJS, ESM, file extensions, resolution priority, and package.json configurations. With Bun, it just works.

TypeScript

TypeScript is a first-class citizen in Bun. Directly execute .ts and .tsx files. Bun respects your settings configured in tsconfig.json, including "paths", "jsx", and more.

Web-standard APIs

Bun implements the Web-standard APIs you know and love, including fetch, ReadableStream, Request, Response, WebSocket, and FormData.

JSX

JSX just works. Bun internally transpiles JSX syntax to vanilla JavaScript. Like TypeScript itself, Bun assumes React by default but respects custom JSX transforms defined in tsconfig.json.

Watch mode

The bun run CLI provides a smart --watch flag that automatically restarts the process when any imported file changes.

Cross-platform shell scripts

The Bun.$ API implements a cross-platform bash-like interpreter, shell, and coreutils. This makes it easy to run shell scripts from JavaScript for devops tasks.

The APIs you need. Baked in.

Start an HTTP server

Start a WebSocket server

Read and write files

Hash a password

Bundle for the browser

Write a test

File system routing

Query a SQLite database

Run a shell script

Call a C function

index.tsx
const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on localhost:${server.port}`);

$ bun install

Bun is an npm-compatible package manager.

Bun

pnpm

17x

npm

29x

Yarn

33x

Installing dependencies from cache for a Remix app.
View benchmark

Node.js compatible

Bun still installs your dependencies into node_modules like npm and other package managers—it just does it faster. You don't need to use the Bun runtime to use Bun as a package manager.

Crazy fast

Bun uses the fastest system calls available on each operating system to make installs faster than you'd think possible.

Workspaces

Workspaces are supported out of the box. Bun reads the workspaces key from your package.json and installs dependencies for your whole monorepo.

Global install cache

Download once, install anywhere. Bun only downloads a particular version of a package from npm once; future installations will copy it from the cache.

Security by default

Unlike other package managers, Bun doesn't execute postinstall scripts by default. Popular packages are automatically allow-listed; others can be added to the trustedDependencies in your package.json.

Cross-platform package.json scripts

On Windows, package.json scripts are powered by the Bun Shell. It's now safe to delete cross-env, rimraf and node-which.

Familiar API

Bun's CLI uses commands and flags that will feel familiar to any users of npm, pnpm, or yarn.

Reads .npmrc & package-lock.json

Migrate from npm without changing dependency versions. Try bun install secretly without telling your coworkers.

Binary lockfile

After installation, Bun creates a binary bun.lockb lockfile with the resolved versions of each dependency. The binary format makes reading and parsing much faster than JSON- or Yaml-based lockfiles.

Replace yarn with bun install to get 30x faster package installs.

$ bun test

Bun is a test runner that makes the rest look like test walkers.

Bun

Vitest

5x slower

Jest+SWC

8x slower

Jest+tsjest

18x slower

Jest+Babel

20x slower

Running the test suite for Zod
View benchmark

Jest-compatible syntax

Bun provides a Jest-style expect() API. Switch to bun test with no code changes.

Crazy fast

Bun's fast startup times shine in the test runner. You won't believe how much faster your tests will run.

Lifecycle hooks

Run setup and teardown code per-test with beforeEach/afterEach or per-file with beforeAll/afterAll.

ESM, TypeScript & JSX just work

Zero configuration needed to test TypeScript, ESM, and JSX files.

Snapshot testing

Full support for on-disk snapshot testing with .toMatchSnapshot(). Overwrite snapshots with the --update-snapshots flag.

DOM APIs

Simulate DOM and browser APIs in your tests using happy-dom.

Watch mode

Use the --watch flag to re-run tests when files change using Bun's instantaneous watch mode.

Function mocks

Mock functions with mock() or spy on methods with spyOn().

Replace jest with bun test to run your tests 10-30x faster.

1

Install Bun

curl -fsSL https://bun.sh/install | bash

2

Write your code

index.tsx
const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on localhost:${server.port}`);

3

Run the file

bun index.tsx

Learn by example.

Our guides break down how to perform common tasks with Bun.